// * 
// * ExPOUND Navigation Layer
// * 
// * 
// * @copyright 2007 Loughborough University
// * @license http://www.gnu.org/licenses/gpl.txt
// * @version 0.0.0.1
// * @since Sept 2009
// * /

import flash.events.Event;

import mx.controls.Alert;
import mx.core.Application;
import mx.managers.PopUpManager;

import mxml_views.navigation_layer;

public var nav_layer:navigation_layer;

private function displayNewNavLayer():void {
	nav_layer = navigation_layer(PopUpManager.createPopUp(this, navigation_layer, true));
	PopUpManager.centerPopUp(nav_layer);
	
	//add an event listener
	nav_layer["btnOkay"].addEventListener("click", SaveNavLayerProperties);
}

private function displayNavLayer():void {
	nav_layer = navigation_layer(PopUpManager.createPopUp(this, navigation_layer, true));
	PopUpManager.centerPopUp(nav_layer);
	
	//access the properties of the layer to display on screen
	nav_layer.txtCopyright.text = Application.application._ProjectProperties._displayCopyright;
	
	if(Application.application._ProjectProperties._displayHomeButton){
		nav_layer.chkHomeBtn.selected;
	}
	
	if(Application.application._ProjectProperties._displayNextButton){
		nav_layer.chkNextBtn.selected;
	}
	
	if(Application.application._ProjectProperties._displayPreviousButton ){
		nav_layer.chkPreviousBtn.selected;
	}
	
	if(Application.application._ProjectProperties._displayNumbers){
		nav_layer.chkScreenNos.selected;
	}
	
	//add an event listener
	nav_layer["btnOkay"].addEventListener("click", SaveNavLayerProperties);
}

private function SaveNavLayerProperties(event:Event):void{


	Application.application._ProjectProperties._displayCopyright = nav_layer.txtCopyright.text;
	
	if(nav_layer.chkHomeBtn.selected == true){
		Application.application._ProjectProperties._displayHomeButton = true;
	}else{
		Application.application._ProjectProperties._displayHomeButton = false;
	}
	
	if(nav_layer.chkNextBtn.selected == true){
		Application.application._ProjectProperties._displayNextButton = true;
	}else{
		Application.application._ProjectProperties._displayNextButton = false;
	}
	
	if(nav_layer.chkPreviousBtn.selected == true){
		Application.application._ProjectProperties._displayPreviousButton = true;
	}else{
		Application.application._ProjectProperties._displayPreviousButton = false;
	}
	
	if(nav_layer.chkScreenNos.selected == true){
		Application.application._ProjectProperties._displayNumbers = true;
	}else{
		Application.application._ProjectProperties._displayNumbers = false;
	}
	
	//var OutputTest:String = new String();
	//OutputTest = Application.application._ProjectProperties._displayCopyright + " - ";
	//OutputTest = OutputTest + Application.application._ProjectProperties._displayHomeButton + " - ";
	//Alert.show(OutputTest.toString());
	
	//remove the pop-up window
	PopUpManager.removePopUp(nav_layer);
	
}